#include "stdafx.h"

InfoAnimation::InfoAnimation(int x, int y) :AbstractAnimation()
{
}

InfoAnimation::~InfoAnimation()
{
}

bool InfoAnimation::update(double dtime)
{
	time += dtime;

	if (time >= time2)
	{
		return false;
	}
	else if (time >= time1)
	{
		alpha = maxAlpha * (time2 - time) / (time2 - time1);
	}
	else if (time >= time0)
	{
		alpha = maxAlpha;
	}
	else
	{
		alpha = maxAlpha * time / time0;
	}

	return true;
}

bool InfoAnimation::render()
{
	ProgramMgr::getInstance()->get("img")->uniform1f("transparency", alpha);

	bool success = img->render(x, y, 0);
	if (!success)
	{
		std::cerr << "error rendering img";
	}

	ProgramMgr::getInstance()->get("img")->uniform1f("transparency", 1.0f);

	return success;
}